using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AfruPhone.Helper_Classes
{
    public class ServiceContainer : IServiceProvider
    {
        private Dictionary<Type, Object> _items;
        private Object _mainService;
        private Type _mainServiceType;

        public ServiceContainer()
        {
            _items = new Dictionary<Type, object>();
        }

        internal void AddService(Type type, Microsoft.Xna.Framework.GraphicsDeviceManager Graphics)
        {
            if (!_items.ContainsKey(type))
                _items.Add(type, Graphics);
        }

        public object GetService(Type type)
        {
            if (_items.ContainsKey(type))
            {
                _mainService = _items[type];
                _mainServiceType = type;
            }
            return null;
        }

        #region IServiceProvider Members

        object IServiceProvider.GetService(Type serviceType)
        {
            if (_items.ContainsKey(serviceType))
            {
                _mainService = _items[serviceType];
                _mainServiceType = serviceType;
            }
            return null;
        }

        #endregion
    }
}
